Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

spdy-transport

Package Overview
Dependencies
Maintainers
3
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spdy-transport

SPDY v2, v3, v3.1 and HTTP2 transport

  • 2.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12M
increased by6.24%
Maintainers
3
Weekly downloads
 
Created

What is spdy-transport?

The spdy-transport package is an npm module that provides a stream-based API for SPDY protocol communication. It is designed to work with both SPDY/3.1 and HTTP/2, and it can be used to create SPDY or HTTP/2 servers and clients in Node.js.

What are spdy-transport's main functionalities?

SPDY/HTTP2 server creation

This code sample demonstrates how to create a SPDY/HTTP2 server using the spdy-transport package. The server listens on port 3000 and responds with 'hello world!' to all requests.

const spdy = require('spdy');
const http = require('http');

const server = spdy.createServer({
  spdy: {
    protocols: ['h2', 'spdy/3.1', ...],
    plain: false,
    'x-forwarded-for': true,
    connection: {
      windowSize: 1024 * 1024, // Server's window size
      autoSpdy31: false
    }
  }
}, (req, res) => {
  res.writeHead(200);
  res.end('hello world!');
});

server.listen(3000);

SPDY/HTTP2 client creation

This code sample shows how to create a SPDY/HTTP2 client using the spdy-transport package. The client connects to 'https://www.example.com' and sends a GET request to the root path.

const spdy = require('spdy');
const http2 = require('http2');

const client = spdy.connect('https://www.example.com', (err, socket) => {
  if (err) {
    throw new Error(err);
  }

  const req = http2.request({
    ':method': 'GET',
    ':path': '/'
  });

  req.on('response', (headers) => {
    // handle headers
  });

  req.on('data', (chunk) => {
    // handle data
  });

  req.on('end', () => {
    console.log('request ended');
  });

  req.end();
});

Other packages similar to spdy-transport

Keywords

FAQs

Package last updated on 02 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc